home *** CD-ROM | disk | FTP | other *** search
/ PC & Mediji 1998 February / PCM_9802.iso / programi / director / data.z / Behavior Library.cst / 00034_Script_UI Radio Group Item < prev    next >
Text File  |  1997-05-09  |  3KB  |  102 lines

  1. -- Setting  Radio   Group Item
  2.  
  3. -- control, drag this onto a system radio button to add it to a group
  4. -- check if it works for push button, check box, radio button
  5.  
  6. -- will receive setRadioValue, getRadioValue, radio_button_selected, groupname 
  7. -- which_radio_button_selected returns the text of the selected item of the group
  8.  
  9. property  GroupName, GroupSetting
  10. property  selectedButton, default
  11.  
  12. on mouseUp me
  13.   setGroupValue me
  14. end
  15.  
  16. on beginSprite me
  17.   if default = TRUE then
  18.     SendAllSprites #clearGroup, groupname
  19.     set selectedButton = the spritenum of me
  20.     setgroupValue me
  21.   else
  22.     SendAllSprites #clearGroup, groupname
  23.   end if
  24. end
  25.  
  26. on getRadioValue me, GName
  27.   if GName = the GroupName of me then
  28.     dontPassEvent
  29.     return the text of member (the member of sprite (the selectedButton of me))
  30.   end if
  31. end
  32.  
  33. on setRadioValue me, GName, selected_sprite_num
  34.   set MNum  = the member of sprite (the spritenum of me)
  35.   
  36.   if GName = the GroupName of me then   
  37.     if the spritenum of me <> selected_sprite_num then
  38.       radioHilite me, FALSE
  39.     end if
  40.     set the selectedButton of me to selected_sprite_num 
  41.   end if
  42. end
  43.  
  44.  
  45. on setGroupValue me  
  46.   SendAllSprites #SetRadioValue, the GroupName of me, the spritenum of me
  47.   radioHilite me, TRUE
  48. end
  49.  
  50. on clearGroup me, gname
  51.   if  GName = the GroupName of me then
  52.     if default = FALSE then
  53.       radioHilite me, FALSE
  54.     else
  55.       radioHilite me, TRUE
  56.     end if  
  57.   end if
  58. end
  59.  
  60.  
  61. ---
  62.  
  63. on getPropertyDescriptionList
  64.   
  65.   return [¼
  66.   #GroupName: [ #default: #group1, #format:#symbol, #comment:"Group Name"], ¼
  67.   #default  : [ #default: 0, #format:#boolean, #comment:"Initially Selected?"] ¼
  68.   ]
  69.   
  70. end
  71.  
  72. on getBehaviorDescription
  73.   return ¼
  74. "Includes the current sprite in a radio button group. Attach to toggle buttons controlled by the UI Toggle Button behavior, or radio buttons created with the Radio Button tool on the Tools palette. The GetRadioValue message returns the text of the selected button. "&RETURN&¼
  75. "PARAMETERS:"&RETURN&¼
  76. "ò Group Name - Enter the name of the group to which this radio button belongs.  Only one member of the group can be selected at at time. Do not use spaces."&RETURN&¼
  77. "òáInitially Selected - Turn this option on to make this radio button selected when the sprite first appears.  If more than one radio button has Initially Selected on, the highest numbered sprite is selected. "&RETURN&¼
  78. "MESSAGES:" & RETURN & ¼
  79. "ò GetRadioValue group_name - Returns the text of the named radio group's selected button." & RETURN & ¼
  80. "ò SetRadioValue group_name, sprite_number - Sets the named radio button group's setting to be the sprite."& RETURN & ¼
  81. "ò SetGroupValue - Sets the sprite to the group setting."
  82. end
  83.  
  84.  
  85.  
  86. on getAssocMembers --added, fmk
  87.   set myPropList = [  ]
  88.   
  89.   return myPropList
  90. end getAssocMembers
  91.  
  92.  
  93.  
  94. on RadioHilite me, val
  95.   -- assumes if the sprite is not of type button, that it is a toggle button.  If it's neither no adverse effect.
  96.   if ( the type of member ( the memberNum of sprite ( the spriteNum of me)) = #button)  then
  97.     set the hilite of member (the member of sprite (the spritenum of me)) to val
  98.   else
  99.     sendSprite (the spritenum of me, #setToggleValue, val )
  100.   end if
  101. end
  102.